﻿namespace Standards.Data
{
    using System.Collections.Generic;

    using Qi.Data;
    using System;

    public class PermissionDto : Entity
    {
        private Permission permission;

        private IList<RoleDto> roles;

        public Permission Permission
        {
            get { return this.permission; }
            set { this.permission = value; }
        }

        public string PermissionAsString
        {
            get
            {
                return this.permission.ToString();
            }

            set
            {
                Permission result;
                if (Enum.TryParse(value, out result))
                {
                    this.permission = result;
                    return;
                }

                this.permission = Permission.None;
            }
        }

        public IList<RoleDto> Roles
        {
            get
            {
                return this.roles ?? (this.roles = new List<RoleDto>());
            }
            
            set
            {
                this.roles = value;
            }
        }
    }
}